<template>
	<view>
		<uni-easyinput id="input" suffixIcon="search" v-model="parameter.title" placeholder="输入关键字搜索资源"
			@iconClick="sourceList()" />

		<uni-list>
			<uni-list-item v-for="(i_, i) in type" :key="i" :title="i_.name" note="长期置顶" link
				:to="'/pages/mine/sourceList?type='+i_.id+'&name='+i_.name" :clickable="true" :thumb="i_.img" thumb-size="lg"
				rightText="点击查看">
			</uni-list-item>
		</uni-list>
		
		<uni-list>
			<uni-list-item v-for="(i_, i) in list" :key="i" :title="i_.title" :note="i_.createTime" link
				:to="'/pages/mine/sourceInfo?id='+i_.id" :clickable="true" :thumb="i_.img" thumb-size="lg"
				rightText="点击查看">
			</uni-list-item>
		</uni-list>

		<div id="page">
			<uni-pagination @change="sourceList()" :pageSize="parameter.pageSize" :total="parameter.total"
				:current="parameter.pageNum" :value="parameter.pageNum" />
		</div>
	</view>

</template>
<script>
	import {
		type,
		list
	} from '@/api/source.js'

	export default {
		data() {
			return {
				type: [],

				parameter: {
					title: null,
					// 数据总量
					total: 0,
					// 每页数据量
					pageSize: 20,
					// 当前页
					pageNum: 1
				},
				list: []
			};
		},
		onLoad() {
			type().then(res => {
				this.type = res.data
			});
			this.sourceList();
		},
		methods: {
			sourceList() {
				list(this.parameter).then(res => {
					if (res.code == 200) {
						this.parameter.total = res.total
						this.list = res.rows
					}
				})
			}
		}
	}
</script>
<style lang="scss">
	#input {
		padding: 2px 3px;
	}

	#source {
		padding: 0px 3px;
	}
</style>